<template>
  <div class="my-header"  v-show="$route.meta.istrun">
    <div class="big-box">
      <div class="logo">
        <img src="../assets/logo-white.png" alt="" />
      </div>
      <div class="dingwei">
        <button>成都</button>
      </div>
      <div class="nav_content" v-for="(obj, index) in arr" :key="index">
        <router-link class="router" :to="obj.path">
          <span :class="{ active: index === findIndex }" @click="btn(index)">{{
            obj.first_name
          }}</span></router-link
        >
      </div>
      <!-- 实现导航栏跳转到相关页面 -->
      <!-- <router-link
        class="nav_content"
        v-for="(data, index) in arr"
        :to="data.path"
        custom
        v-slot="{ navigate }"
        :key="index"
      >
        <span @click="navigate" :class="{ active: index === findIndex }">
          {{ data.first_name }}
        </span>
      </router-link> -->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [
        {
          path: "/",
          first_id: "0",
          first_name: "首页",
        },
        {
          path: "/esthetics",
          first_id: "1",
          first_name: "整体软装",
        },
        {
          path: "/housecustom",
          first_id: "2",
          first_name: "全屋定制",
        },
        {
          path: "/aesproducts",
          first_id: "3",
          first_name: "美学产品",
        },
        {
          path: "/",
          first_id: "4",
          first_name: "服务案例",
        },
        {
          path: "/",
          first_id: "5",
          first_name: "体验馆",
        },
        {
          path: "/",
          first_id: "6",
          first_name: "楼盘团购",
        },
        {
          path: "/",
          first_id: "7",
          first_name: "关于我们",
        },
        {
          path: "/",
          first_id: "8",
          first_name: "软装百科",
        },
        {
          path: "/",
          first_id: "9",
          first_name: "公司动态",
        },
      ],
      findIndex: 0,
    };
  },
  methods: {
    btn(index){
      this.findIndex = index;
    },
  },
};
</script>

<style lang="scss" scoped>
.my-header {
  background-color: #212529;
  width: 100%;
  margin: 0 auto;

  .big-box {
    width: 90%;
    height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .logo {
      width: 137px;
      height: 35px;
      padding: 10px;
      padding-left: 20px;
      background-color: #262626;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .dingwei {
      button {
        padding: 10px 20px;
        border-radius: 5px;
        border: none;
        background-color: #dead75;
      }
    }
    .nav_content {
      white-space: nowrap;
      padding: 0 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      // color: white;


      .router {
        color: white;
        font-size: 16px;
        text-decoration: none;
        &:hover {
          color: #dead75;
        }

        // span {
        // &.active {
        //   color: #dead75;
        // }
        // }
      }
      
    }
  }
}
</style>

<style lang="css" scoped>
.nav_content .active {
  color: #dead75;
}
</style>